/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.http.client.jersey.server.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * class info
 *
 * @author hujia
 * @date 2018/10/29 20:29
 */
@Component
@Slf4j
public class TestFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        log.info(((HttpServletRequest) request).getRequestURI());
        chain.doFilter(request, response);
        int status = ((HttpServletResponse) response).getStatus();
        log.info("the response code is " + status);
        log.info(response.getContentType());
        log.info(response.getOutputStream().toString());
    }

    @Override
    public void destroy() {

    }
}
